package ar.com.raulsanchez.syncrolist;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ActividadAdapter extends ArrayAdapter<Actividad> {

	int resource;
	String response;
    Context context;

	public ActividadAdapter(Context context, int resource, List<Actividad> items) {
		super(context, resource, items);
		this.resource = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
    {
		LinearLayout actividadView;
		
        //Get the current object
        Actividad ac = getItem(position);

        //Inflate the view
        if(convertView==null)
        {
            actividadView = new LinearLayout(getContext());
            String inflater = Context.LAYOUT_INFLATER_SERVICE;
            LayoutInflater vi;
            vi = (LayoutInflater) getContext().getSystemService(inflater);
            vi.inflate(resource,actividadView,true);
        }
        else
        {
        	actividadView = (LinearLayout) convertView;
        }
        //Get the text boxes from the listitem.xml file
        TextView txtTitulo =(TextView)actividadView.findViewById(R.id.txtTitulo);
        TextView txtFecha  =(TextView)actividadView.findViewById(R.id.txtFecha);
         
        //Assign the appropriate data from our alert object above
        txtTitulo.setText(ac.getTitulo());
        txtFecha.setText(ac.getFecha());
         
        return actividadView;
    }

}